package com.tukez.tmdb

import scala.concurrent.ops.future
import http.HttpResponse
import com.tukez.tmdb.query.Order
import com.tukez.tmdb.query.OrderBy
import org.joda.time.DateTimeZone
import com.tukez.tmdb.model.Movie
import org.specs2.ScalaCheck
import com.tukez.tmdb.model.Person
import org.joda.time.LocalDate

class TMDbPersonSpecBase extends TMDbSpecBase with ScalaCheck {

  def checkOnePerson(person: Person) = {
    person.id must_== 100
    person.name must_== "Scott Speedman"
    person.score must beNone
    person.popularity must_== 3
    person.biography must_== "biography is here"
    person.url must_== "http://www.themoviedb.org/person/100"
    person.version must_== 208
    person.last_modified_at.toDateTime(DateTimeZone.UTC).toString() must_== "2011-11-21T14:11:14.000Z"
    person.profile map { _.width } must_== List(45, 185, 484)
    person.profile forall { _.`type` == "profile" } must beTrue

    person.details must beSome
    val details = person.details.get
    details.known_movies must_== 2
    details.birthday must_== new LocalDate(1975, 9, 1)
    details.birthplace must_== "London, England, UK"

    details.known_as must contain("alt1", "alt2").only.inOrder

    details.filmography must have size 2
    details.filmography(0).id must_== 20
    details.filmography(0).name must_== "My Life Without Me"
    details.filmography(0).release must_== new LocalDate(2003, 9, 4)
    details.filmography(1).id must_== 277
    details.filmography(1).name must_== "Underworld"
    details.filmography(1).release must_== new LocalDate(2003, 9, 19)
  }

  def checkThreePersons(person1: Person, person2: Person, person3: Person) = {
    person1.id must_== 139261
    person2.id must_== 515107
    person3.id must_== 440683

    person1.name must_== "Nathanael 'Brad' Dunham"
    person2.name must_== "Brad Kavanagh"
    person3.name must_== "Brad Womack"

    person1.score must beSome(5)
    person2.score must beSome(4)
    person3.score must beNone

    person1.last_modified_at.toDateTime(DateTimeZone.UTC).toString() must_== "2011-11-07T14:54:34.000Z"
    person2.last_modified_at.toDateTime(DateTimeZone.UTC).toString() must_== "2011-10-26T09:39:16.000Z"
    person3.last_modified_at.toDateTime(DateTimeZone.UTC).toString() must_== "2011-11-23T15:27:30.000Z"
    
    person1.profile map { _.width } must_== List(45, 185)
    person2.profile must beEmpty
    person3.profile must beEmpty

    person1.details must beNone
    person2.details must beNone
    person3.details must beNone
  }
}